#ifndef FERMAT_LIBHTTP_HTTP_HEADER_SIZE_H_
#define FERMAT_LIBHTTP_HTTP_HEADER_SIZE_H_
#include <fermat/libhttp/http_common_header.h>
#include <vector>
#include <string>

namespace fermat {
namespace libhttp {

class HttpHeaders{
public:
	typedef std::function<bool(std::string *name, std::string &name)> HeaderFilter; 
public:
	HttpHeaders();
	~HttpHeaders();
	HttpHeaders(const HttpHeaders &);
	HttpHeaders& operator=(const HttpHeaders &other);
	HttpHeaders(HttpHeaders&&);
	HttpHeaders& operator=(HttpHeaders&&);

	void add(const std::string &name, const std::string &value);

	void add(HttpHeaderCode code, const std::string &value);

	void set(const std::string &name, const std::string &value);

	void set(HttpHeaderCode code, const std::string &value);

	bool exists(const std::string &name) const;

	bool exists(HttpHeaderCode code) const;

	bool remove(HttpHeaderCode code);

	bool remove(std::string &name);

	size_t size();

	void clear();

	void runFilter(const HeaderFilter &filter);

	const std::string getSingleOrEmpty(const std::string &name);

	const std::string getSingleOrEmpty(HttpHeaderCode code);

	size_t getNumOfHeader(HttpHeaderCode code);

	size_t getNumOfHeader(std::string &name);

	std::vector<std::string> getHeaderAll(std::string &name);

	std::vector<std::string> getHeaderAll(HttpHeaderCode code);
private:
	static const size_t          kInitSize = 16;
	size_t                       _deleteSize;
	std::vector<HttpHeaderCode>  _codes;
	std::vector<std::string*>    _headerNames;
	std::vector<std::string>     _headerValues;
private:
	void disposeHeaderOwned();
};

}
}
#endif